// app.js
App({
  globalData: {
    userInfo: 11111,
    news:{
      Date:null,
      title:null,
      writer:"中巨",
      main:null,
    },
    id:'',
    openid:'',
    headimg:"",
    age:"",
    huancun:{
      xingming:"",
      shenfenzheng:"",
      shoujihao:"",
      xiangxidizhi:"",
      shengshiqu:["","",""],
      jianhuren:[]
    },
    baocunshenfenzheng:""
  },
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    // 登录
  },
  // 手动触发下拉刷新的方法
  pullDownRefresh: function () {
    // 显示下拉刷新动画
    wx.startPullDownRefresh({
      success: function () {
        // 模拟异步操作，假设1秒后完成
        setTimeout(function () {
          // 关闭下拉刷新动画
          wx.stopPullDownRefresh();
        }, 1000);
      }
    });
  },
fetchData: function() {
  const that =this;
  return new Promise((resolve) => {
    // 异步请求数据
    wx.login({
      success: res => {
        this.globalData.id=res.code
        wx.request({
          url: 'https://dj.ifankui.com/api/wx/autoLogin',
          method:"POST",
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          data:{
              code:this.globalData.id,
          },
          success(res){
              that.globalData.openid=res.data.openid
              resolve(res.data.openid);
          }
        })
      }
    })
  });
},
})
